﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="房产销冠, 房地产,卡考网络" />
    <meta name="description" content="上海卡考网络有限公司" />
    <title>房产销冠</title>
    <link rel="stylesheet" href="css/global.css" type="text/css" />
    <link rel="stylesheet" href="css/form.css" type="text/css" />
    <link rel="stylesheet" href="css/default.css" />
    <link href="bootstrap/iCheck-master/skins/minimal/orange.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="css/gri.controls.css" type="text/css" />
    <link rel="stylesheet" href="css/bootstrap-switch.css" type="text/css" />
    <script src="http://dn-blqw.qbox.me/jq+bs+art.js" type="text/javascript"></script>
    <script src="js/jquery-form.js" type="text/javascript"></script>
    <script src="js/underscore.js" type="text/javascript"></script>
    <script src="js/jquery-my-Extension.js" type="text/javascript"></script>
    <script src="js/kk.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/WdatePicker.js"></script>
    <!--<script type="text/javascript" src="js/dateRange.js"></script>-->
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/formValidator.js"></script>
    <!--图片上传-->
    <link href="Scripts/webuploader/webuploader.css" rel="stylesheet" />
    <script type="text/javascript" src="bootstrap/iCheck-master/icheck.js"></script>
    <script type="text/javascript" src="js/bootstrap-switch.min.js"></script>
    <script src="Scripts/webuploader/webuploader.min.js" type="text/javascript"></script>
    <script src="Scripts/webuploader/webupload.expand.js" type="text/javascript"></script>
    <script type="text/javascript">
    </script>
    <!--<script charset="utf-8" src="js/kindeditor-min.js"></script>-->
    <!--<script charset="utf-8" src="js/zh_CN.js"></script>-->
    <script type="text/javascript">

    </script>
</head>
<body style="background: #f1f1f1;">
    <div class="main01 pb50">
        <div class="fromtit1 clearfix">
            <h1 class="ff">活动设置</h1>
            <a href="#" class="gouback" onclick="f_Back();">返回</a>
        </div>
        <div class="frommod clearfix">
            <form id="form1">
                <table border="0" cellspacing="0" cellpadding="0" class="fromtab1" style="width:800px;">
                    <tr>
                        <th>活动时间：&nbsp;</th>
                        <td>
                            <input type="text" id="beginTime" name="beginTime" class="inpall" value="" onclick="WdatePicker()" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd',minDate: '%y-%M-%d' })" placeholder="请选择时间" />
                            -至-&nbsp;<input type="text" id="endTime" name="endTime" class="inpall" value="" onclick="WdatePicker()" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'beginTime\')}' })" placeholder="请选择时间" />
                        </td>
                    </tr>
                    <tr>
                        <th>每日活动时间：&nbsp;</th>
                        <td>
                            <input type="text" id="beginHour" class="inpall inp80 fl" maxlength="2" value="12" placeholder="12" onkeyup="clearNoPhone_Number(this)" />
                            <span class="inpword fl">时</span>
                            <input type="text" id="beginMinute" class="inpall inp80 fl" maxlength="2" value="00" placeholder="00" onkeyup="clearNoPhone_Number(this)" />
                            <span class="inpword fl">分</span>
                            <input type="hidden" id="exchangeBeginTime" name="exchangeBeginTime" />
                            <div class="fl">至</div>
                            <input type="text" id="endHour" class="inpall inp80 fl" maxlength="2" value="18" placeholder="18" onkeyup="clearNoPhone_Number(this)" />
                            <span class="inpword fl">时</span>
                            <input type="text" id="endMinute" class="inpall inp80 fl" maxlength="2" value="00" placeholder="00" onkeyup="clearNoPhone_Number(this)" />
                            <span class="inpword fl">分</span>
                            <input type="hidden" id="exchangeEndTime" name="exchangeEndTime" />
                        </td>
                    </tr>
                    <tr>
                        <th>每人抽奖次数：&nbsp;</th>
                        <td>
                            <input type="text" id="TurnTime" name="TurnTime" value="2" class="inpall inp435" placeholder="请输入每人抽奖次数" validatetype="*number" onkeyup="clearNoPhone_Number(this)" maxlength="10" />
                        </td>
                    </tr>
                    <tr>
                        <th>每次抽奖消耗积分：&nbsp;</th>
                        <td>
                            <input type="text" id="TurnPoint" name="TurnPoint" value="50" class="inpall inp435" placeholder="请输入每次抽奖消耗积分" validatetype="*number" onkeyup="clearNoPhone_Number(this)" maxlength="10" />
                        </td>
                    </tr>
                    <tr>
                        <th>活动开关：&nbsp;</th>
                        <td style="width: 120px;">
                            <div class="make-switch" id="F_IsOpen" data-switch-get="state" data-on-label="开启" data-off-label="关闭">
                                <input type="checkbox" name="F_IsOpen" class="isOpen" />
                                <input type="hidden" id="isOpen" value="0" name="isOpen" />
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <div class="sinput">
                                <input type="button" class="Save" value="保存" onclick="f_Save()" />
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            f_Switch();
            f_GetSetting();
        });

        function f_Back() {
            self.location = document.referrer;
        }

        function f_Save() {
            if ($("#beginTime").val() == null || $("#beginTime").val() == "" || $("#beginTime").val() == undefined || $("#endTime").val() == null || $("#endTime").val() == "" || $("#endTime").val() == undefined) {
                $kk.popup("请选择活动时间", "err", 1000); return;
            }

            var bHour = $("#beginHour").val();
            var eHour = $("#endHour").val();
            function isHour(num) {
                if (!isNaN(num) && num >= 24 && num >= 0) {
                    $kk.popup("请重新输入有效的两位小时数(如15)", "err", 3000); return;
                }
            }
            isHour(bHour);
            isHour(eHour);

            var bMinute = $("#beginMinute").val();
            var eMinute = $("#endMinute").val();
            function isMinute(num) {
                if (!isNaN(num) && num >= 60 && num >= 0) {
                    $kk.popup("请重新输入有效的两位分钟数(如25)", "err", 3000); return;
                }
            }
            isMinute(bMinute);
            isMinute(eMinute);
            if (bHour > eHour) {
                $kk.popup("开始时间不允许小于结束时间", "err", 3000); return;
            }
            if ((bHour == eHour) && (bMinute > eMinute)) {
                $kk.popup("开始时间不允许小于结束时间", "err", 3000); return;
            }
            $("#exchangeBeginTime").val(bHour + ":" + bMinute);
            $("#exchangeEndTime").val(eHour + ":" + eMinute);


            var data = {
                beginTime: $('#beginTime').val(),
                endTime: $('#endTime').val(),
                exchangeBeginTime:$("#exchangeBeginTime").val(),
                exchangeEndTime:$("#exchangeEndTime").val(),
                isOpen: $("#isOpen").val(),
                turnTime:$('#TurnTime').val(),
                turnPoint:$('#TurnPoint').val()
            }
            if (data.turnTime==''||data.turnTime==0) {
                $kk.popup("每人抽奖次数不能小于1", "err", 3000); return;
            }
            if (data.turnPoint == '') {
                $kk.popup("每次抽奖消耗积分不能为空", "err", 3000); return;
            }
            kk.api.get("/LuckBigTurntable/LuckActivitySetting", data, function (res) {
                if (res) {
                    $kk.popup("操作成功", "success", 1000);
                } else {
                    $kk.popup("操作失败", "danger", 1000);
                }
            });
        }

        function f_GetSetting()
        {
            kk.api.get("/LuckBigTurntable/LuckActivityGet", {}, function (res) {
                if (res) {
                    $('#beginTime').val(res.beginTime);
                    $('#endTime').val(res.endTime);
                    $("#exchangeBeginTime").val(res.exchangeBeginTime);
                    $("#exchangeEndTime").val(res.exchangeEndTime);
                    $("#isOpen").val(res.isOpen);
                    $('#TurnTime').val(res.turnTime);
                    $('#TurnPoint').val(res.turnPoint);

                    var stime = res.exchangeBeginTime;
                    var etime = res.exchangeEndTime;

                    var arrStime = stime.split(':');
                    var arrEtime = etime.split(':');

                    $("#beginHour").val(arrStime[0]);
                    $("#beginMinute").val(arrStime[1]);

                    $("#endHour").val(arrEtime[0]);
                    $("#endMinute").val(arrEtime[1]);

                    if (res.isOpen==1) {
                        $("#F_IsOpen").find("div").removeClass("switch-off").addClass("switch-on");
                    }
                } else {
                    $kk.popup("无法获取活动配置", "danger", 2000);
                }
            });
        }

        function f_Switch() {
            $('#F_IsOpen').on('switch-change', function (e, data) {
                if (!data.value) {
                    $("#isOpen").val("0");
                } else {
                    $("#isOpen").val("1");
                }
                //alert($('#isOpen').val());
            });
        }
    </script>
</body>
</html>
